{% extends 'CouponBundle:Coupon:layout.html.twig' %}

{% block title %}生成优惠码 - {{ parent() }}{% endblock %}

{% set menu = 'coupon_batch' %}

{% set script_controller = 'couponbundle/controller/coupon/generate' %}

{% set submenu = 'coupon_batch' %}

{% block main %}

<div class="page-header clearfix">
  <h1 class="pull-left">生成优惠码</h1>
</div>
<form id="coupon-generate-form" class="form-horizontal" action="{{ path('admin_coupon_generate') }}" method="post">

  <fieldset>
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="name">优惠码名称</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" name="name" class="form-control" id="name">
      </div>
    </div>
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="type">优惠方式</label>
      </div>
      <div class="col-md-7 controls">
        <div class="radios">
          <label><input type="radio" name="type" value="minus" checked="checked"> 抵价</label>
          <label><input type="radio" name="type" value="discount"> 打折</label>
        </div>
      </div>
    </div>
    <div class="row form-group minus-rate">
      <div class="col-md-2 control-label">
        <label for="minus-rate">抵价金额</label>
      </div>
      <div class="col-md-3 controls">
        <input type="text" id="minus-rate" name="minus-rate" class="form-control">
      </div>
      <div style="margin-top:5px;">元</div>
    </div>
    <div class="row form-group discount-rate" style="display:none;">
      <div class="col-md-2 control-label">
        <label for="discount-rate">打折</label>
      </div>
      <div class="col-md-3 controls">
        <input type="text" id="discount-rate" name="discount-rate" class="form-control">
      </div>
      <div style="margin-top:5px;">折</div>
    </div>
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="generatedNum">生成数量</label>
      </div>
      <div class="col-md-3 controls">
        <input type="text" id="generatedNum" name="generatedNum" class="form-control">
        <div class="help-block">生成数量必须在1～1000之间</div>
      </div>
      <div style="margin-top:5px;">个</div>
    </div>
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="prefix">优惠码前缀</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" name="prefix" class="form-control" id="prefix" data-url="{{ path('admin_coupon_checkprefix') }}">
        <div class="help-block">优惠码前缀不可重复，不占优惠码位数</div>
      </div>
    </div>
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="digits">优惠码位数</label>
      </div>
      <div class="col-md-3 controls">
        <input type="text" id="digits" name="digits" class="form-control" value="8">
        <div class="help-block">优惠码位数必须在5～15位之间</div>
      </div>
    </div>
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="coupon-deadline">有效期至</label>
      </div>
      <div class="col-md-3 controls">
        <input type="text" name="deadline" id="coupon-deadline" class="form-control" value="">
      </div>
    </div>
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="description">优惠说明</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="description" name="description" class="form-control">
      </div>
    </div>
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="target">使用对象</label>
      </div>
      <div class="col-md-3 controls">
        <select class="form-control" name="targetType">
          <option value="course" selected="selected">课程</option>
        </select>
      </div>
    </div>
    <div class="row form-group">
      <div class="col-md-offset-2 col-md-2">
        <div class="radio">
          <label>
            <input type="radio" name="courseId" id="all-courses-input" value="0" data-toggle="modal"  checked="checked">全部课程
          </label>
        </div>
        <div class="radio">
          <label>
            <input type="radio" name="courseId" id="choose-course-input" data-toggle="modal" data-target="#modal"  data-url="{{ path('admin_course_chooser') }}" value="">
            指定课程
          </label>
        </div>
      </div>
      <div class="col-md-5" style="display:none;" id="course-display">
        <div class="well" style="width:200px;display:inline-block;margin:0px;"></div>
        <a style="margin-left:10px;"type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#modal"  data-url="{{ path('admin_course_chooser') }}" >重新选择</a>
      </div>
    </div>
    <div class="row form-group">
      <div class="col-md-offset-2 col-md-1">
        <input type="submit" class="btn btn-primary pull-left" value="生成">
      </div>   
      <div class="col-md-1">
        <a href="{{ path('admin_coupon') }}" class="btn btn-link">取消</a>
      </div>
    </div>
    <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
  </fieldset>

</form>

{% endblock %}
